// 序列号规则
import React, {Component} from 'react'
import UpListPage from './UpList';
import DownListPage from './DownList';
import Actions from './ActionStore/Actions';


export default class ListSerialrulePage extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            rowObj: null,
            matchedRows: '', //table列表需要选中的行  ListSerialrulePage    InstructionAppointment
        };
        this.unsubscribe = Actions.rowClickHandle.listen( (rowObj) => {
            if(rowObj.length > 0){
                this.setState({
                    rowObj: rowObj[0].data,
                    matchedRows: rowObj[0].rowIndex,
                });
            }
        });
    }

    componentWillUnmount() {
        console.log("组件销毁");
        this.unsubscribe();
    }

    render() {
        let searchCondition;
        if(this.state.rowObj != null){
            //上部表格的选中行，提取关联字段放入下部表格的查询条件
            searchCondition = {ruleCode: this.state.rowObj.ruleCode};

            // matchedRows = this.state.matchedRows;
            console.log('-------------',searchCondition);
        }
        return (
                <div>
                    <UpListPage matchedRows={this.state.matchedRows}/>

                    <DownListPage searchCondition={ searchCondition } />

                </div>
        );
    }
}
